#pragma rtGlobals=1		// Use modern global access method.
function xps_conv(nb)
string nb
string fileName
variable p,n,q =1 
n = 0
Notebook $nb selection={(0,0), (0,0)}
Notebook $nb findText={"BE_",1}
Notebook $nb selection={startOfParagraph, endOfChars}
Getselection notebook,$nb, 3
fileName = Replacestring( "BE_", S_selection, "")
fileName = Replacestring(",", fileName, "")
p = strlen(fileName)

do
	fileName = RemoveEnding(fileName)
	n += 1
while ( n <  p/2) 

Print fileName
NewNotebook /F=0/N=$fileName as fileName

do
	Notebook $nb selection={startOfNextParagraph, endOfNextParagraph}
	Getselection notebook, $nb, 3
	//print S_selection
	
	if ( stringmatch(S_selection, "\r") == 0)
		Notebook $fileName text=S_selection
	endif
	
	if (stringmatch(S_selection,"\r") == 1)
		SaveNotebook $fileName as fileName
		DoWindow /K $fileName
		Notebook $nb findText={"BE_",1}
		q = V_flag
		
		if (q == 0)
			break
		endif

		Notebook $nb selection={startOfParagraph, endOfChars}
		Getselection notebook,$nb, 3
		fileName = Replacestring( "BE_", S_selection, "")
		fileName = Replacestring(",", fileName, "")
		p = strlen(fileName)
		n=0

		do
			fileName = RemoveEnding(fileName)
			n += 1
		while ( n <  p/2) 

		Print fileName
		NewNotebook /F=0/N=$fileName as fileName
	endif

while (q == 1)
end function